package com.xinchao.ck_mips.broadcast;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;

/**
 * Created by wq on 2019/4/25.
 * 开机自启广播
 */
public class AutoLaunchBroadCast extends BroadcastReceiver {
    /**标识开机启动*/
    public static final String FLAG = "COMPLETE";
    @Override
    public void onReceive(Context context, Intent intent) {
        //开机自启动应用
       /* Intent launchIntent = context.getPackageManager().getLaunchIntentForPackage(context.getPackageName());
        launchIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
        context.startActivity(launchIntent);*/
        Intent bootIntent = new Intent();
        bootIntent.setClass(context, HomeWatcherService.class);
        bootIntent.putExtra(FLAG,FLAG);
        bootIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        context.startService(bootIntent);
    }
}
